package br.com.fogas.webservice.repository.soap;

import android.content.Context;
import br.com.fogas.utils.exception.ParseXmlException;
import br.com.fogas.webservice.exception.RespostaWebServiceException;
import br.com.fogas.webservice.exception.SemConexaoInternetException;
import br.com.fogas.webservice.exception.ServidorForaException;
import br.com.fogas.webservice.exception.TempoEsperaRespostaException;
import br.com.fogas.webservice.exception.WebServiceException;
import br.com.fogas.webservice.parser.condicoes.CondicoesEnvelope;
import br.com.fogas.webservice.parser.condicoes.CondicoesRequest;
import br.com.fogas.webservice.parser.condicoes.CondicoesResponse;
import br.com.fogas.webservice.repository.IRepositoryHandler;
import br.com.fogas.webservice.soap.impl.CondicoesSOAP;

public class CondicoesRepository implements IRepositoryHandler<CondicoesResponse> {

	private Context context;
	
	private CondicoesRequest request;

	public CondicoesRepository(Context context, CondicoesRequest request) {
		this.context = context;
		
		this.request = request;
	}
	
	@Override
	public CondicoesResponse getResponse() throws SemConexaoInternetException,
			ParseXmlException, TempoEsperaRespostaException,
			ServidorForaException, RespostaWebServiceException,
			WebServiceException {
		CondicoesEnvelope envelope = new CondicoesEnvelope();
		envelope.body.request = request;

		CondicoesSOAP soap = new CondicoesSOAP(context, envelope);
		return soap.getResponse();
	}

}
